# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入鼠标操作类
from selenium.webdriver.common.action_chains import ActionChains
# 获取浏览器驱动
driver = webdriver.Firefox()
driver.maximize_window()
# 打开测试的网址
url = 'file:///C:/Users/tedu/Desktop/NSD2407/html/drop.html'
driver.get(url)
# 2.创建鼠标操作对象
action = ActionChains(driver)
# 将源元素拖拽到目标元素的位置
src = driver.find_element(By.CSS_SELECTOR, '#div1')
dest = driver.find_element(By.CSS_SELECTOR, '#div2')
# 3.鼠标拖拽
action.drag_and_drop(src, dest).perform()
sleep(3)
# 4.按照偏移量拖拽
action.drag_and_drop_by_offset(dest, xoffset=800, yoffset=400).perform()

# 停顿3秒，关闭浏览器
sleep(3)
driver.quit()